Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ts-graphviz/ast

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ts-graphviz/ast

Graphviz AST(Abstract Syntax Tree) Utilities

  • 2.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created

What is @ts-graphviz/ast?

@ts-graphviz/ast is an npm package that provides an Abstract Syntax Tree (AST) for Graphviz's DOT language. It allows you to parse, manipulate, and generate DOT files programmatically using TypeScript.

What are @ts-graphviz/ast's main functionalities?

Parsing DOT Files

This feature allows you to parse a DOT string into an AST. The code sample demonstrates how to parse a simple DOT string and output the resulting AST.

const { parse } = require('@ts-graphviz/ast');
const dot = 'digraph G { a -> b; }';
const ast = parse(dot);
console.log(JSON.stringify(ast, null, 2));

Generating DOT Files

This feature allows you to generate a DOT string from an AST. The code sample demonstrates how to create a simple AST and convert it back to a DOT string.

const { print } = require('@ts-graphviz/ast');
const ast = {
  type: 'Graph',
  id: 'G',
  body: [
    { type: 'EdgeStatement', edge_list: [{ id: 'a' }, { id: 'b' }] }
  ]
};
const dot = print(ast);
console.log(dot);

Manipulating AST

This feature allows you to manipulate the AST before converting it back to a DOT string. The code sample demonstrates how to add a new edge to the graph.

const { parse, print } = require('@ts-graphviz/ast');
let dot = 'digraph G { a -> b; }';
let ast = parse(dot);
ast.body.push({ type: 'EdgeStatement', edge_list: [{ id: 'b' }, { id: 'c' }] });
dot = print(ast);
console.log(dot);

Other packages similar to @ts-graphviz/ast

FAQs

Package last updated on 27 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc